Skip to main content

database

Database DML function

DML is short name of Data Manipulation Language which deals with data manipulation, and includes most common SQL statements such as SELECT, INSERT, UPDATE, DELETE etc, and it is used to store, modify, retrieve, delete and update data in database.

Centurion uses a simplified DML strategy of files with functions where each file is the focus of a single parent table and its children. There are several tables in the Centurion Postgres database. See the DDL for the database here.

  • FEEDS
  • CHAINS
  • HISTORY
  • NONCES
  • WALLETS
  • FALLBACK_WALLETS
  • PRICES
  • USERS
  • SYMBOLS
  • HISTORY_TIMESTAMPS
  • SIGNED_DATA
  • ALERT_HISTORY
  • CONFIGURATIONS
  • API_PROVIDERS_UNION

Files can be found in two locations. The first is in the /utils/ folder. Here files are considered universal to the entire code base of the project. For the most part they are generic (e.g. getEnabledChains()).

/utils
|__database
|__feedsDB.js
|__pricesDB.js
|__ ...

The other locations are files called database.js within the folder of a worker such as pricesWorker, see an example here. These files contain DML that is very specific to the worker. The functions within should not be updated to satisfy the need of any code outside the worker's folder. The pricesWorker can and does use functions from utils/database/... as well as its own ./database.js file.